<?php
 /**
 * Created by PhpStorm.
 * @package    art
 * @copyright  Copyright (c) 2013 LaZaDa SEA
 * @author     long.nguyen-thanh <long.nguyen-thanh@lazada.com
 * @date       5/20/14 5:28 PM
 * @ID         $Id$,${Id}
 */

$title 			= $this->formText('title',$this->Item['title'],array('class'=>'form-control', 'placeholder' => 'Title'));
$address 		= $this->formText('address',$this->Item['address'],array('class'=>'form-control', 'placeholder' => 'Address'));
$type 			= $this->formText('type',$this->Item['type'],array('class'=>'form-control', 'placeholder' => 'Type'));
$date 		    = $this->formText('date',$this->Item['date'],array('class'=>'form-control', 'data-provide' => 'datepicker', 'placeholder' => 'Date'));
$location	    = $this->formText('location',$this->Item['location'],array('class'=>'form-control', 'placeholder' => 'Location'));
$time	 	   	= $this->formText('time',$this->Item['time'],array('class'=>'form-control', 'placeholder' => 'Time'));
$description   	= $this->formTextarea('description',$this->Item['description'],array('class'=>'form-control form-margin-left', 'rows' => 8, 'placeholder' => 'Description'));
$fullname   	= $this->formText('full_name',$this->Item['full_name'],array('class'=>'form-control', 'placeholder' => 'Full name'));
$backgound_color = $this->formText('bg_color',$this->Item['bg_color'],array('class'=>'form-control','style'=>'margin-left:-2px', 'placeholder' => 'Color'));
$text_color 	= $this->formText('text_color',$this->Item['text_color'],array('class'=>'form-control', 'placeholder' => 'Color'));
$image 			= $this->formFile('image',array('class'=>'image-upload', 'placeholder' => 'Image'));



$linkPost = $this->cmsUrl(array('action'=>'add-events'));

$linkLoadAjaxLogin = $this->cmsUrl(array(
										'module' => 'default',
										'controller' => 'index',
										'action' => 'ajax-login',
										'action-page' => 'add-events'
									));
									

$userInfo = new Zendvn_System_Info();
$userInfo = $userInfo->getMemberInfo();
if(empty($userInfo)){
	echo '<script>
			$(function(){
				$.get("' . $linkLoadAjaxLogin . '", function(data){
					$(".fancybox-inner").html(data);
				})
			})
		  </script>';
}else{
?>
<div id="area_data">
	<div class="row">
	    <div class="box">
	    	<div class="col-md-10 col-md-offset-1 list-error" id="list-error" style="display: none"></div>
	    	<div class="clr">
	    		<h4 id="event_title" style="margin: 0px 0px 20px 0px; text-align: center">POST AN EVENT/EXHIBITION/PUBLICATION ANNOUNCEMENT</h4>
	    	</div>
			<form class="form-horizontal" role="form" id="appForm" name="appForm" action="<?php echo $linkPost?>" method="post" enctype="multipart/form-data" >
				<div class="form-group col-md-6">
		        	<label class="col-md-4 col-xs-2 control-label">TITLE</label>
				     <div class="col-sm-4 column-input-4">
						<?php echo $title?>
					</div>
		      	</div>
		      	<div class="form-group col-md-6">
		        	<label class="col-md-4 col-xs-2 control-label">ADDRESS</label>
				     <div class="col-sm-4 column-input-4">
						<?php echo $address?>
					</div>
		      	</div>
		      	
		      	<div class="form-group col-md-6">
		        	<label class="col-md-4 col-xs-2 control-label">TYPE</label>
				     <div class="col-sm-4 column-input-4">
						<?php echo $type?>
					</div>
		      	</div>
		      	<div class="form-group col-md-6">
		        	<label class="col-md-4 col-xs-2 control-label">DATE</label>
				     <div class="col-sm-4 column-input-4">
						<?php echo $date?>
					</div>
		      	</div>
		      	
		      	<div class="form-group col-md-6">
		        	<label class="col-md-4 col-xs-2 control-label">LOCATION</label>
				     <div class="col-sm-4 column-input-4">
						<?php echo $location?>
					</div>
		      	</div>
		      	<div class="form-group col-md-6">
		        	<label class="col-md-4 col-xs-2 control-label">TIME</label>
				     <div class="col-sm-4 column-input-4 bootstrap-timepicker"">
						<?php echo $time?><span class="add-on">
	      <i data-time-icon="icon-time" data-date-icon="icon-calendar">
	      </i>
	    </span>
					</div>
		      	</div>
		      	
		      	<div class="form-group col-md-12">
		        	<label class="col-md-2 col-xs-2 control-label">DESCRIPTION</label>
				     <div class="col-sm-4 column-input-8" id="des_event">
						<?php echo $description?>
					</div>
		      	</div>
		      	
		      	<div class="form-group col-md-5" id="bg_color">
		        	<label class="col-md-5 col-xs-2 control-label">BACKGROUND COLOR</label>
				     <div class="col-sm-5">
						<?php echo $backgound_color?>
					</div>
		      	</div>
		      	<div class="form-group col-md-5" id="bg_color">
		        	<label class="col-md-7  col-xs-2 control-label">TEXT COLOR</label>
				     <div class="col-sm-5">
						<?php echo $text_color?>
					</div>
		      	</div>
		      	<div class="form-group col-md-7" id="bg_color">
		        	<label class="col-md-5  col-xs-2 control-label">ATTACH AN IMAGE</label>
				     <div class="col-sm-7 column-input-3">
						<?php echo $image?>
	                     <button type="button" class="btn btn-default bg-blue">UPLOAD</button>
                         <span id="icon-success" style="display: none" class="glyphicon glyphicon-ok icon-success"></span>
					</div>
		      	</div>
		      	
		      	
	
		      	<div class="form-group col-md-12" id="fullname">
		        	<label class="col-md-2 col-xs-2 control-label">FULL NAME</label>
				     <div class="col-sm-6  col-xs-8">
						<?php echo $fullname?>
					</div>
		      	</div>
		      	
		      	
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-9" style="text-align: right">
						<button type="submit" class="btn btn-default bg-blue">PUBLISH</button>
					</div>
				</div>
			</form>
		</div>
	</div>

<?php 
	$linkEventFinish = $this->cmsUrl(array(
										'module' => 'default',
										'controller' => 'index',
										'action' => 'donate',
									));	
?>

	<script>
		$(function(){
			$(".fancybox-inner").niceScroll();
			$('#date').datepicker({ format: 'mm/dd/yyyy',});
			var input = $('#time').clockpicker({
				placement: 'bottom',
				align: 'left',
				autoclose: true,
				'default': 'now'
			});
	
			$('#time').on('focusout', function(){
				input.clockpicker('hide');
			})
			
			$('#full_name').tagsInput(
                {
                    width:'auto',
                    defaultText: 'Full name'
                }
            );

            $("#image").on('change',function(){
                $('#icon-success').show();
            });
			
	        $('#bg_color,#text_color').ColorPicker({
	            onSubmit: function(hsb, hex, rgb, el) {
	                $(el).val(hex);
	                $(el).ColorPickerHide();
	            },
	            onBeforeShow: function () {
	                $(this).ColorPickerSetColor(this.value);
	            }
	        })
	            .bind('keyup', function(){
	            $(this).ColorPickerSetColor(this.value);
	        });
	
			$('#appForm').ajaxForm({ 
		        // dataType identifies the expected content type of the server response 
		        dataType:  'json', 
		 
		        // success identifies the function to invoke when the server response 
		        // has been received 
		        success: function(data){
		        	$('form[name="appForm"] div.frm-input').addClass('has-success');
		    		//$('form[name="appForm"] div.frm-input input').after('<span class="glyphicon glyphicon-ok form-control-feedback"></span>');
		    		$('#list-error').html('').hide();
					if(data.type == "error"){
						for(var x in data.msg){
							$('input#' + x).parent().parent().addClass('has-error');
							$('input#' + x).parent().find('span.glyphicon').removeClass('glyphicon-ok').addClass('glyphicon-remove');
							$('#list-error').append('<div class="alert alert-danger" id="list_device_alert"><strong>' + data.msg[x] + '</strong></div>');
						}
						$('#list-error').fadeIn();
					}else{
						$.get("<?php echo $linkEventFinish?>", function(data){
							$(".fancybox-inner").html(data);
						})
						/*$('form[name="appForm"] span.tag').remove();
						$('form[name="appForm"] #full_name').val('');
						$('form[name="appForm"] div.frm-input').removeClass('has-success').removeClass('has-error');
						$('span.form-control-feedback').remove();
						$('#appForm')[0].reset();
						$('#list-error').html('<div class="alert alert-success" id="list_device_alert"><strong>Congratulation! Adding new item is successful</strong></div>').fadeIn().delay(3000).fadeOut();*/
					}
		        } 
		    });
		})
		
	</script>
</div>
<?php }?>